home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fritz: All Fritz
/
All Fritz.zip
/
All Fritz
/
FILES
/
PROGMISC
/
FPCHELP.LZH
/
F-PC.TXT
< prev
next >
Wrap
Text File
|
1988-08-11
|
50KB
|
1,366 lines
F-PC.TXT THE F-PC USERS MANUAL
Table of contents
Overview F-PC, What is it all about _______________ 2
1. Getting Started __________________________ 2
2. Sequential File Forth: An Overview ________ 6
3. What is the same as F83? __________________ 8
4. What is different from F83? _______________ 9
5. Differences from PF, ZF & DF ______________ 10
6. SED: The Editor ___________________________ 11
7. The Debugger, and the Tools Available _____ 19
8. DOS: The interface ________________________ 25
9. Memory Management in F-PC _________________ 27
10. The File System and Handles _______________ 28
11. Rebuilding the System _____________________ 28
12. F-PC and Batch Files ______________________ 29
13. Extra stuff included with F-PC ____________ 30
14. Forth History: how did we get here? _______ 30
Overview F-PC, What is it all about?
The first thing you should know is that F-PC is trying to
achieve a number of conflicting goals. With F-PC I am trying
to provide a Forth system that provides all of the following:
A system that is familiar to the large
installed base of F83 users.
A system that brings Forth fully into the
realm of files.
A Forth system that is as unstrange as
possible to C and Pascal programmers.
A system which maintains Forths interactive
nature.
A system which if FAST to compile and run.
A FAT system with many tools, which still
has room for an application program.
Impossible, you say. Perhaps, but I think if you give F-PC a
chance you may find some things you like.
In line with the above goals, here is a list of some of
F-PC's major features.
Direct threaded dictionary for speed.
Seperated lists & heads to increase space.
Prefix assembler to enhance readability.
Assembler supports both Prefix as well as
Postfix assembly syntax for familiarity.
Full DOS access from system and COMMAND
level control.
Full Handle/Path based file system.
View works across directory boundries.
The editor provides pull-down menus, and
online help as well as being user
configurable.
Full DOS memory managment interface.
Much more of course is provided, but enough of this
editorializing. Let's get started.
1. Getting Started
F-PC is a Forth system whose origins can be traced back to
F83. F-PC has been tailored to use sequential files for source,
and all references to BLOCK have been removed. While this may
seem very strange at first, allow me a few minutes, and you
will, I believe, find F-PC to be more familiar than you might
expect.
Installing F-PC
F-PC is provided in archive form on a three floppy disks,
which you have already copied onto your hard disk and
expanded or you wouldn't be reading this. To install F-PC,
you will need only type the name of the batch file which will
allow you to set some user configurable parameters, and set
the paths of some of the files to your current directory
structure.
Type: INSTALL <enter>
If you don't have a batch file called INSTALL.BAT, then you
can type the command manually as follows:
Type: F-PC - INSTALL <enter>
Either of the above will install F-PC, configuring it for
your computer and directory structure in the process.
Starting F-PC
Once F-PC has been installed on your computer, you can start
it up by typing "F <enter>" from the keyboard. This will
display a signon message about the version number, available
memory, etc. An additional information screen can be viewed
by typing INFO <enter>.
Opening a file:
Type the following: OPEN BANNER <enter>
The file BANNER.SEQ will be opened. We can load it with:
1 LOAD <enter>
This prints a nice demo message. This demo came from the
F83X system.
We can edit the source for BANNER by typing:
ED <enter>
You will now be in the editor, viewing the first 20 lines
or so of BANNER.SEQ. You can page down through the file with
the PgDn key on the keypad, and back up with the PgUp key.
For now, page down to the bottom of the file with PgDn, and
there you see the definition of the word DEMO, which prints
out our demonstration banner.
Now let's create a new file and put a new DEMO definition
with our own banner message in it. Leave the editor by
typing "ESC Q D" for Quit Discard, or by pressing Alt-F10.
You will now be back in Forth without saving any changes you
may have accidently made to BANNER.SEQ.
To create the new file, type the following:
NEWFILE MYBANNER <enter>
F-PC will start the editor, and try to open the file
MYBANNER. If it is present, F-PC will open it. If it is not,
then F-PC will automatically create a new file called
MYBANNER.SEQ and place you in the editor in that file,
prepared to enter text.
Type in the following definition, using the <enter> key to
add new lines to the file as needed. The arrow keys can be
used to move around, but you will not be allowed to move
below the line containing the little up pointing triangle at
the left edge of the screen, as this represents the end of
the current file.
: MYBANNER ( --- )
" HELLO" BANNER
" FROM" BANNER
" YOURNAME" BANNER ;
Note that YOURNAME must be no longer than 11 characters.
Now that you have typed in or edited the above definition
into the file BANNER.SEQ, leave the editor saving the text
you have entered, by pressing "ESC Q S", for Quit and Save.
This time, as we REALLY DO want to save the program.
Let's compile the program. Type:
FLOAD MYBANNER <enter>
The file MYBANNER.SEQ is opened, and loaded. If you
entered the program as shown, then all should be well, and
Forth should come back with the "ok" message. You could have
compiled the program by typing 1 LOAD <enter>, since the file
was already open.
Now that MYBANNER is compiled, type its name to make it do
it's stuff:
MYBANNER <enter>
You should have seen your name scroll up on the screen, if
you didn't, try editing the source file and correcting your
typing error.
At this point, you can VIEW the source for MYBANNER by
typing:
VIEW MYBANNER <enter>
F-PC will locate the source for your MYBANNER word, and
display the source file starting at the line where MYBANNER
was started. A shorter word for VIEW called LL (Locate &
List) is provided to save typing.
Now let's look at some Forth words with LL, and some of the
other file traversal words. Type:
LL DUP <enter>
The HELP information for DUP will be displayed on the top
few lines, with the source for DUP displayed below it, with
the line where the definition of DUP starts underlined. Above
the line where DUP starts is the reverse video message
showing the filename of the source for DUP. Now type:
N <enter>
The screen will blink and display group of lines starting
16 lines farther into the KERNEL1.SEQ source file. With the
"N" word, you can scan quickly through a sequential file.
The inverse of "N" is "B". If you type it followed by
<enter>, the previous 16 lines will be displayed. Another
display word "L" is provided to redisplay the current
location in the file again.
One last word you will find VERY useful is WORDS. It is
used as follows:
WORDS HE <enter>
The above command sequence will display all words in all
vocabularies of Forth that contain the letter sequence "HE".
This is very useful when you don't know how to spell the word
you are looking for, but you know it contains a particular
character sequence. WORDS by it self will show all words in
the current vocabulary only, and the special sequence "*.*"
following WORDS is recognized as a command to display all
words of all vocabularies.
Here is a list of the words we have covered.
OPEN <filename> <enter> Opens filename.
1 LOAD <enter> Compiles the open file.
ED <enter> Starts editing the current
file.
NEWFILE <filename> <enter> Specifies a file to edit.
FLOAD <filename> <enter> Loads filename.
HELP <enter> Displays a help screen.
HELP <forth_word> <enter> Shows the help and or source
VIEW <forth_word> <enter> for a Forth word.
LL <forth_word> <enter>
N <enter> Shows next 16 lines.
B <enter> Shows previous 16 lines.
L <enter> Re-display current 16 lines.
WORDS <sub_string> <enter> Display all words containing
<sub_string> in all vocabularies.
SEE <word> Decompile the memory copy of
the word, and show the source.
2. Sequential File Forth: An Overview
Much of what is in F-PC came from F83, and should be somewhat
familiar. Things that are different, are normally different
because they need to be. There are a significant number of
things about F83 that I would have liked to change, but did
not for compatibility reasons. However since BLOCK is not
present, you will experience a period of difficulty. I hope
you will take some solace in knowing I have at least tried to
make the transition as painless as possible. Many of the
familiar file manipulation words from F83 are still present,
and those that are will work in a very similar if not
identical way. Some of these are:
OPEN, CLOSE, VIEW, OK, L, N, B, ED, LOAD, LIST, EDIT
Some words like BLOCK, and BUFFER, simply could not be fit
into the new scheme of things in a logical manner, and so
were omitted. To load an entire file, use the sequence FLOAD
<filename>. Listing through a file is best done with VIEW,
although of course the file will have already had to be
loaded. To LIST through a file which has not been loaded, you
can use LIST, which lists from a line number, rather than
from a block, but the following sequence is easier.
OPEN <filename> <enter> opens file
L <enter> lists first 18 lines
N <enter> lists next group of lines.
B <enter> list previous group of lines.
These words are very fast using indices into the file to
maintain their line pointer information.
the word LOAD still exists, but loads the rest of a file
starting at the line number specified.
The compiler in F-PC has been tailored to be as fast as I
could make it. Since much of the functionality of WORD has
been moved into CODE for performance, this system compiles
sequential text files much faster than standard F83 compiles
BLOCKs.
The debugger has been enhanced to allow nesting and
un-nesting of ":" definitions for more capable debugging.
The editor is WordStar compatible from a cursor control key
stand point, with the keypad functions fully supported,
along with some function keys. Full search, replace, and
global replace are provided, along with copy and paste of
text segments within a file as well as between files. The
editor provides pull down menus for ease of learning, and
Control or Alt equivalants for speed of operation.
A utility is provided to convert even very large BLOCK
files into sequential files. The resulting savings in mass
storage is typically greater than 60%.
The source for F-PC is, of course, provided. You can tailor
it to your way of doing things if you don't like mine.
3. What is the same as F83?
From a low-level Forth standpoint, F-PC is very similar to
F83.
Multi-tasking is unchanged.
The assembler in POSTFIX mode is fully compatible with the
F83 assembler.
VIEW, FIX, L, N, B, ED, LISTING, and OK work as they did
in F83.
LOAD and LIST need a line number rather than a screen
number.
\S is available, and stops compilation of the remaining
portion of the current file.
DBG and DEBUG work as they did in F83, with more
functionality added. A decompiled source of the current
definition being debugged is displayed at the top of the
screen.
SEE is available, but has been enhanced to display the
conditional structures in nested source form, for much
increased readability.
WORDS works as it did in F83, with the enhancement that you
can specify a text string following it to display a subset
of words in the dictionary that contain the substring. WORDS
*.* will display all words in all vocabularies.
4. What is different from F83?
The system is now Direct threaded CODE. This results in
the CODE fields of Colon definitions being 3 bytes instead
of 2. Approximately a 15% increase in performance results.
The LIST portion of all ":" definitions has been moved to
another segment. This allows programs to be as large as
memory. A small loss of performance resulted. (about 10%)
System based time and date functions have been added, for
measurement as well as display of the time and date. The
word TIMER will allow measuring the performance of various
operations in F-PC.
Very fast screen I/O is provided for editor and normal text
display. The words FAST and SLOW switch between direct
screen I/O and BDOS function I/O.
Screen hi-lighting for a monochrome display is supported
for underline, bold, reverse, bold blink, and reverse blink.
Paths are fully supported, as entered from the command
line, or applied to a file automatically if not specified.
Many DOS command line functions are built-in, like DIR,
COPY, FORMAT, DEL, REN, MD, RD, CHDIR, PATH, and more may be
added at a cost of about 40 bytes each.
Cursor shape control is provided, in the form CURSOR-ON,
CURSOR-OFF, NORM-CURSOR, MED-CURSOR, BIG-CURSOR, GET-CURSOR,
and SET-CURSOR.
BLOCK, BUFFER, B/BUF, C/L, and BLK can be loaded from the
file BLOCK.SEQ.
The word COPY, is now a DOS function to copy files.
Environment access is supported, see the ENVIRON.SEQ file.
5. Differences from PF, ZF & DF
This Forth was implemented by Tom Zimmer, with substatial
help from Robert L. Smith. All of the Direct Threaded low
level code modifications came from Bob's LaForth
implementation.
This is yet another step in the Forth evolution being
undertaken to obtain the ideal Forth system. This Forth
maintains fairly high compatibility with ZF & DF which was
it's predecessor. The primary problem that you are likely to
encounter, is that CODE fields are three (3) bytes rather
than 2, and the CODE field of a CODE word does not point to
code, but contains code.
F-PC has moved ":" LISTs to a seperate segment, so there are
two bytes in the BODY of each ":" definition that points into
LIST space the the ":" definitions LIST of CFAs. LIST space
is accessed with L words, like L@ and L!.
VARIABLEs, CONSTANTs, and strings are handles in the same
way as F83, that is they are in CODE space. This segmentation
seems to provide a reasonable balance. As the dictionary
expands, more user data space is needed, which works well with
F-PC, as most of the free space is in CODE/DATA space.
This system will full circle meta compile and extend, with
the provided batch files for simplicity.
As F-PC currently exists, there is about 50k of LIST
dictionary space, and 40k of CODE space. which can be expanded
by removing some of the optional files from the list of load
files in F-PC.SEQ. List can also be expanded by assigning a
new value into the VALUE #LISTSEGS. The removable files are
marked. Some of these files are listed as follows:
PATHSET.SEQ WORDS.SEQ COLOR.SEQ DUMP.SEQ
DECOM.SEQ DEBUG.SEQ STATUS.SEQ MACROS.SEQ
PATCHER.SEQ FILSTAT.SEQ FWORDS.SEQ
If some of these files are removed, a significant savings in
dictionary space will result.
A tool of the type used in F83X has been added, called
NEEDS. This word when followed by a filename will
conditionally load the specified file if the file has not
already been loaded. Be sure to include the filename
extension. Another word UNWANTED, when followed by a
filename, aborts with an error if the Unwanted file has
already been loaded.
6. SED the Editor
For full information on the editor in F-PC, please see the
file SED.TXT
7. The Debugger, and the Tools Available
THE DEBUGGER
The debugger is very similar to the F83 debugger. Some
features have been added to enhance its operation. The
decompiled source for the current definition being debugged
is displayed while debugging. A typical command sequence
might be as follows:
DEBUG WORDS <enter> specify WORDS to be debugged
as soon as it is executed.
or
DBG WORDS <enter> debug WORDS right now.
Once in the debugger, you will be shown a display similar
to the following:
17469 INWFLG ?> _
At this point, pressing return will cause the word INWFLG
to be executed, and the debugger will print the stack after
execution, and step to the next word in the list and wait for
a command. Notice the fields in the above example. The
number on the left is the address in memory where the
debugger is currently working. The next word INWFLG is the
word the debugger is about to execute. The next symbol "?>"
is a marker pointing to what will be the printed stack
contents after we press <enter>. The question mark symbol is
the command we must press to see the command list for the
debugger. If we press that now, we will see:
C-cont, F-forth, Q-quit, N-nest, U-unnest:
These are the commands you can use in the debugger. Their
functions are as follows:
C-cont Trace continuously until a key is pressed.
F-forth Allow entry of Forth command lines until
<enter> is pressed on an empty line.
Q-quit Quit the debugger, and unpatch next.
N-nest Nest into the ":" definition we were about
to execute. Only works on ":" definitions,
and deferred words.
U-unnest Unnest the current ":" definition being
debugged. Re-enters the debugger on the next
higher level.
DEBUGGING with SOURCE displayed
You will have noticed that the upper portion of the screen
is filled with the source for the word you are currently
debugging. This is to make it easier to follow the debug
process. You may want to turn off the source display, if it
interferes with your the debuging process. The words to
control this are:
SRCOFF turn off the source display
SRCON turn on the source display
The default state is ON.
CONSTANTS as VARIABLES and what to do with them
A set of operators has been included for manipulating
constants. Since constants are faster at run time than
variables, performance critical operations can take advantage
of these. They may also provide a somewhat more readable
source. Here is a list of them:
=: \ value =: constant-name
!> \ value !> constant-name
\ assign value into constant-name
@> \ @> constant-name ( --- n1 )
\ returns contants of its BODY.
+!> \ value +!> constant-name
\ increment constant-name by value
incr> \ incr> constant-name
\ increment constant-name by one
decr> \ decr> constant-name
\ decrement constant-name by one
These operators are written in assembly, so they will be
very fast.
SEEing into Forth definitions
F-PC provides the standard F83 decompiler, called SEE. SEE
has been modified to display a decompiled source that is in
most cases the very similar to the source on disk.
TIMER and measurement of execution time
A complete set of time and date manipulation words has been
provided, here is an explanation of their usage:
TIMER ( words --- )
TIMER performs the Forth words following on the same
command line, and when they finish execution, TIMER prints
the elapsed time required for their execution.
TIME-RESET ( --- )
Reset the accumulated time value in the double variable
STIME to zero, in effect resetting the current elapsed time
to zero. This word is used at the beginning of a sequence of
operations you want to time. The word .ELAPSED is used at
the end of the operations to print the elapsed time since the
last TIME-RESET.
.ELAPSED ( --- )
Print the elapsed time since the last TIME-RESET was
performed.
TENTHS ( tenths_ofa_second --- )
SECONDS ( seconds --- )
MINUTES ( minutes --- )
HOURS ( hours --- )
Time delay words use the system time function to obtain
very accurate time delays. Background processing continues,
as pause is called in the wait loop. Another deferred word,
PAUSE-FUNC, is also in the loop, which can be re deferred to
perform any function you want done while the delay is
occurring.
DATE Control Words
F-PC provides several words for getting and setting the date
and time as follows:
GETDATE ( --- d1 )
Return d1 the 32bit binary date from the operating system.
SETDATE ( d1 --- )
Given the binary date d1, set the system clock to that
date.
GETTIME ( --- d1 )
Return d1 the 32bit binary time from the operating system.
SETTIME ( d1 --- )
Given the binary time d1, set the system clock to that
time.
.DATE ( --- )
Print to the screen, the current date, in the format
MM/DD/YY, where MM is month, DD is day, and YY is year.
.TIME ( --- )
Print to the screen, the current time, in the format
HH:MM:SS.HR, where HH is hours, MM is minutes, ss is seconds,
and HR is hundredths of a second.
Multiple line COMMENT words in F-PC
COMMENT: ( lines_of_text --- )
Starts a group of lines that are to be treated as comments,
until a terminating "COMMENT;" is found.
.COMMENT: ( lines_of_text --- )
Starts a group of lines, that are to be printed to the
terminal, until a terminating "COMMENT;" is found.
SCREEN control words in F-PC
FAST ( --- )
Select the Fast screen output routines that are very
hardware dependant. Much faster than BDOS, but requires VERY
compatible hardware.
SLOW ( --- )
Select the SLOW screen output routines, these routines use
BDOS for screen output, and are less hardware dependant than
FAST.
>UL ( --- ) underline
>REV ( --- ) reverse
>BOLD ( --- ) bold
>BOLDUL ( --- ) bold underline
>BOLDBLNK ( --- ) bold blink
>REVBLNK ( --- ) reverse blink
>NORM ( --- ) normal video
Select the various types of attributes available on the
monochrome monitor.
COLOR support has been added. F-PC as delivered is
configured for Monochrome, but will work on a color monitor.
The INSTALL process will automatically install color support
if a color board is being used during installation.
>FG ( n1 --- ) foreground
>BG ( n1 --- ) background
Words from the COLOR.SEQ file that allow setting the
foreground and background colors on a color monitor:
>ATTRIB1 ( --- )
>ATTRIB2 ( --- )
>ATTRIB3 ( --- )
.
.
>ATTRIB8 ( --- )
Deferred words to allow selection of the various display
attributes for the current display board. They default to
the following attributes for Monochrome and Color.
MONOCHROME COLOR
word bgrnd fgrnd
---------------------------------------------
>ATTRIB1 UNDERLINE BLUE GREEN
>ATTRIB2 BOLD UNDERLINE RED WHITE
>ATTRIB3 BOLD BLUE WHITE
>ATTRIB4 REVERSE RED WHITE
These values can be changed by changing either COLOR.SEQ,
or MONOCROM.SEQ and re-installing the system with INSTALL.BAT.
SAVESCR ( --- ) save screen
RESTSCR ( --- ) restore screen
These words give you the ability to save the screen
contents and later restore the screen to its original
appearance in a simple way. SAVESCR may be used and nested
up to three times before RESTSCR needs to be done. That is,
three screens can be saved and sequentially restored.
COMPILATION control words
OK <enter>
Compile the currently open file, starting at the beginning,
and continuing through the end of the file or until an error
is encountered.
<line_number> LOAD <enter>
Start loading the current file starting at the
<line_number> specified. Loads through the end of the file
or until an error is encountered.
PRINTING Source files in F-PC.
Files can of course be printed while in the editor, but you
can also print files from the Forth command line as follows:
OPEN <filename> <enter> open a file
LISTING <enter> print the file
The print format is the same as the default format for the
editor. Another command which combines the two commands
above is as follows:
FPRINT <filespec> <enter> open and print
Literally opens the file and performs a LISTING. The source
for the word FPRINT is available in the file FWORDS.SEQ
CONDITIONAL COMPILATION
The word #IF has been added, which accepts a boolean flag,
and determines if the lines following #IF are loaded up until
the #ENDIF. A TRUE flag causes the lines to be loaded. A
FALSE flag causes the lines to be skipped.
TRUE #IF
.( This message will be printed.)
#ENDIF
MACROS in F-PC, and SED
A file called MACROS.SEQ is provided, which implements
keyboard macros in Forth, at the level of KEY. These macros
can therefore be used in the editor also. The macros are
used as follows: (the sequence "Alt-M" means hold down the
"Alternate" key and press the "M" key.)
Alt-M start defining a macro.
Alt-1 we are defining the Alt-1 macro.
Enter any keys you want in the macro, up to 128 keys.
Alt-M completes the definition of the Alt-1
macro.
Any keys typeable on the keyboard except Alt-m, and Alt-1
to Alt-5 can be included within a macro.
To execute a macro, simply type its key name:
Alt-1 executes the macro key sequence for
the Alt-1 key.
Currently macros may be only 127 characters in length,
although this can be changed by modifying the MAXMAC constant
and recompiling the system.
REPEAT a MACRO
A function of macro support also allows the repeating of a
macro key up to 999 times as follows:
Alt-R Prompts for number of times to repeat
the macro.
Any number between 1 and 999 may be entered, after doing
this, press the macro key to be repeated, like:
Alt-1 Macro Alt-1 will be repeated the
number of times you requested.
*SECRET*
As it turns out, any key may be repeated with Alt-R, just
press the key you want repeated rather than a macro key.
8. DOS: the interface
The interface to DOS occurs at several levels. In this
section we will discuss the interface to the DOS commands as
opposed to the DOS system calls.
It is convenient to be able to issue DOS commands from
within F-PC. This avoids having to leave F-PC to do the normal
housekeeping things that are regular occurrences in a DOS
based computer. In line with this, F-PC implements a pair of
commands:
$SYS ( a1 --- f1 )
SYS ( text --- )
These words allow performing almost any DOS command line
operation you would want to do. To make things even more
convenient, several additional words have been coded which
use the $SYS word for specific functions. They are as
follows:
DIR FORMAT FTYPE DEL CHDIR COPY REN RD MD PATH
A: B: C:
These commands may be used as they are in DOS. The word
FTYPE replaces the DOS word TYPE for obvious reasons.
If you press Control-C, or Control-Break during the
execution of any of the above words, operation will abort
back to Forth.
` <command> <enter>
BACKTICK followed by one space and a DOS command sequence
performs the DOS command sequence and returns to Forth.
9. Memory Management in F-PC
F-PC uses memory as follows:
|---------------------| ?CS:
^ | |
| | Forth |
| | Kernel |
| | |
| |---------------------|
| | System |
| | Extensions |
| |---------------------| HERE, DP @
| | Dictionary | PAD, DP + 80
| | Free space |
64k | | |
bytes | v |
| | ^ |
| | | |
| | Data stack |
| |---------------------| SP0 @
| | TIB | TIB, 'TIB @
| | | |
| | v |
| | ^ |
| | | |
v | Return stack |
|---------------------| RP0 @, End code space.
|---------------------| YSEG @, Start head space.
^ | hash table |
| |---------------------|
| | |
32k | headers |
bytes | |
| |---------------------| YHERE, YDP @
| | header |
v | free space | YHERE + 32767
|---------------------|
|---------------------| TSEGB, TSEGE
^ | |
64k bytes | Edit Buffer |
v | |
|---------------------| LSEG
| Line pointer list |
|---------------------| DSEG
| Lines deleted buf |
|---------------------| RSEG
| Restore display buf |
|---------------------|
COLON ":" Data Structure
Here is the data structure used for a colon definition in
F-PC.
The COLON ":" definition of the word HEX.
----------------
HEAD SPACE [ VIEW offset ] VIEW
[ LINK pointer ] LINK
[ 83 hex ] NAME
[ H ]
[ E ]
[ X + 80 hex ]
Points to CODE space [ CFA pointer ] --------v
---------------- |
|
---------------- |
CODE SPACE [ CALL ] CFA <---<
[ NEST ]
Points to LIST space [ LIST POINTER ] >BODY @ XSEG @ +
---------------- |
|
---------------- |
LIST SPACE [ cfa of (LIT) ] LIST <--<
[ 16 ]
[ cfa of BASE ]
[ cfa of ! ]
[ cfa of UNNEST]
----------------
10. The File System and Handles
For full information on the file system as used in F-PC,
please see the file FILES.TXT
11. Rebuilding the System.
If you need to change a parameter or function in the F-PC
system, you will need to re-compile F-PC and/or KERNEL. This
is simply done with the provided batch files as follows:
C> FMETA <enter> re-compiles KERNEL.COM
C> EXTEND <enter> re-extends to create F-PC.EXE
C> INSTALL <enter> sets user parameters into F.EXE
All of these may be performed from the keyboard while in
DOS.
TURNKEY
The word TURNKEY and some associated words are included in
the file SAVESYS.SEQ. TURNKEY is used as follows:
' MYAPPL TURNKEY MYAPP.COM <enter>
After completing an application compile, the word MYAPPL
is defined to be performed by the program name MYAPP.COM.
TUNRKEY automatically sets up the proper memory managment to
allocate 64k for your program, but does not save the HEADS.
Minimum initialization is performed. A file specified on the
command line will be opened, and you can use BL WORD to pick
up additional parameters from the command line. You will NOT
of course be able to interpret, since heads are not saved,
and you applicaton will need to handle all errors and return
to DOS when the program completes.
BUILDING an APPLICATION
Before attempting to build an application, you will need to
make a copy of F-PC.SEQ, for customization. Many of the later
files in F-PC.SEQ are utilities, and will not be needed in your
application. Start by writing your program and compiling it
on F-PC.EXE. Work in this environment until you are sure your
program works. Now insert your program filename into the copy
of F-PC.SEQ you made, about half way down, and try to compile
the copy of F-PC.SEQ. If it compiles then you can move your
application file lower, until you have determined what
utilities are needed by your application. Strip out all files
above your application file, and load the file SAVESYS.SEQ.
Use TURNKEY as previously described to make an executable
.COM file. As an alternative to SAVESYS, you can use SAVEEXE to
make an EXE file if your application is to big for a COM file.
12. F-PC and Batch Files.
F-PC allow commands to be passed to Forth on the DOS command
line in the following manner:
C> F-PC <filename> <forth words> <enter>
This example illustrates how you can start F-PC with a
specified file name, and perform commands on the file. An
example of how this might be used is as follows:
C> F-PC BANNER OK <enter>
Here we are starting F-PC with the file BANNER.SEQ, and then
performing OK to compile the file. Another way to use
command line parameters is:
C> F-PC - <forth words> <enter>
Here we are starting F-PC, followed by a dash "-" to tell F-PC
we are not opening a file, then telling F-PC to perform the
Forth words following the "-". Here is an example:
C> F-PC - REPAIR DIR <enter>
This example starts up F-PC without a file and tells F-PC we
want to repair the word DIR. It will locate the word DIR and
start up the editor with the cursor located on the first
line of the DIR definition.
You can get to batch files now, as you can see many types
of commands could be given to F-PC on the command line. Here
are the contents of the META.BAT:
F-PC - FLOAD META86
This single line batch file re-meta-compiles the F-PC kernel
file and re-creates the KERNEL.COM file. A similar batch
file is provided to extend the system.
The one caution on batch files is you must not place
commands on the command line which cause the command line to
be interpreted again. The words HELLO and COLD are such
words, and should not be used on the command line of F-PC.COM,
or KERNEL. Another caution for command lines, is the symbols
"<" and ">" can not be used on the command line since DOS
will think they are re-direction symbols. So don't try to do
any comparisons on the command line.
13. Extra stuff included with F-PC
Please examine the separate file ZIMMER.TXT, CURLEY.TXT and
SMITH.TXT for information on the extras provided with each
archive file. There are many interesting and useful program
segments in these archives, including a FAST software
floating point package.
14. Forth History, how did we get here?
This Forth system started out as an experiment to see if a
development environment could be created that would be as
interactive as a BLOCK Forth system, with as many of the same
tools as possible.
Over the past several years, I have observed the
Programming community for other languages. Several years
ago, Forth had enormous advantages over Fortran, Pascal, and
C in terms of development interactivity. The Forth
development cycle was very short, and new code modules could
be put together for experimentation very quickly. As the
years went by, the Programmers for these other languages
began to realize there had to be something better than their
traditional compile debug cycle, i.e.
----> Enter the editor from operating system.
| | Make changes with LINE editor.
| | Leave editor back to operating system.
| | Start Compiler on source module.
| | WAIT A LONG TIME FOR THE COMPILER.....
| | Discover an error.
| |
| --< LOOP back up until all compile errors are found.
|
| Now start Linker on all modules.
| WAIT A LONG TIME FOR THE LINKER.....
| Discover Link error.
----< Go back to beginning and try again.
The above loop could be measured in DAYS, and was normally
at least 30 minutes long.
Forth did away with much of the above. The editor was
integrated into the Forth/Operating system environment, so
the time to start up or leave the editor was zero. The
compiler was incremental, so programs could be debugged a
piece at a time, and there was no linker at all. This
naturally resulted in a productivity improvement and a
significant reduction in programmer frustration.
As the years went by, other programmers noticed how much
easier BASIC was to use than other compiled languages, since
it had a built in editor, and didn't have to compile at all.
Of course it was SO SLOW.., but then along came TURBO PASCAL.
It created fast compiled code, had an integrated SCREEN
editor, and compiled like BLAZES.
We now start to see some similarities to Forth, a much
superior development environment, where the development
iteration cycle has been reduced to a very small number. But
Turbo Pascal still lacked Forth interactivity, and ability to
incrementally debug programs as they are developed.
Finally along came the Macintosh (Those who know me knew I
would figure out a way to mention it), and Light Speed
Pascal. It had evolved from Mac Pascal, an interactive and
pseudo interpreted Pascal for the Mac. LSP (Light Speed
Pascal) had Windows, a Built in Screen editor, Compiled
modules, a Very fast compiler and a Light Speed Linker, with
the ability to test small segments of code, and two built-in
debuggers: one for Pascal, and one for Assembly. I bought it
and liked the environment very much. The only problem was
that is was PASCAL not Forth. I did, however, like the
advantages of sequential files. Here is a partial list:
Source files are smaller, so backing up or
transporting file is easier.
Sequential source files can be manipulated
or viewed by programs that other people
have, not just by the forth block editor.
There is no artificial limitation placed on
definition size. In the block based system
I was always giving up line zero for a
comment line, and line 15 for nudge space.
There is no artificial limit placed on the
amount of comments I can place with the
source. Again, compared to blocks with
shadows, 16 lines of shadows was either too
much or too little.
Sequential files provide a much more
natural interface to the operating system.
I love being able to insert room for a new
definition in the middle of a source file,
without having to drop out of the editor,
and use MORE and CONVEY to move things
around, all I have to do is press <enter>.
Hmm. I wonder what Forth would be like with Sequential
files? Well, it has arrived.
So here we are at the end (or beginning) of a long road,
looking back at what we have done, and looking forward to
the future. Blocks were certainly very useful for forcing me
to modularize my code. That was a big advantage while I was
learning Forth. Maybe newcomers to Forth should be required
to learn the system on a BLOCK version, but now that I have
come of age, I think I know where to modularize my code
better than the computer.
Thoughts on BLOCK
One last thought. Although all references to block
operations have been removed from F-PC, that does not mean you
cannot use block type disk operations in your programs. Here
is the equivalent F-PC source for some simple block read and
block write functions:
create blockbuf 1024 allot
: BLKREAD ( n1 --- a1 )
1024 um* seek
blockbuf dup 1024 shndl @ hread drop ;
: BLKWRITE ( n1 --- )
1024 um* seek
blockbuf 1024 shndl @ hwrite drop ;
These definitions will read and write a block of data from
the current file. While it is true that the above does not
provide anything like a complete Forth BLOCKs functionality,
like no auto write on update, and no virtual buffering, it
does show how simple it is to access random records in a
file.
Now I hope I have provided some insight into the logic
behind the development of F-PC without BLOCKs. I hope you can
find a use for it as I have.
Tom Zimmer
P.S. for those of you that really want or need BLOCK, there
is a file called BLOCK.SEQ that provides virtual block
support.